<template>
    <div>
        <a href="/Liset">会员列表</a>
        <table>
            <thead>
                <tr>
                    <td>等级名称</td>
                    <td>
                        <input type="text" v-model="data.Dname">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="data.Dmima">
                    </td>
                </tr>
                <tr>
                    <td>等级状态</td>
                    <td>

                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <input type="button" value="添加" @click="add" >
                    </td>
                </tr>
            </thead>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router';//引入引用
//实例化
const rounter=useRouter();


const data=ref({
    "DId": 0,
  "Dname": "",
  "Dmima": "",
  "Dtime": "2025-03-23T07:05:39.138Z",
  "Zhuangtai": false
});




const add=()=>{
    if(data.value.Dname=="")
    {
        alert("名称不能为空");
        return;
    }
    console.log(data.value);
    axios.post("https://localhost:7146/api/Basa/AddDj",data.value).then(res=>{

        if(res.data>0)
        {
            alert("添加成功");
            location.href="/Liset";
        }
        else
        {
            alert("添加失败");
        }
    })
}



</script>

<style scoped>

</style>